package com.zhangxu.junior.controller;

import com.github.pagehelper.PageHelper;
import com.zhangxu.junior.domain.Course;
import com.zhangxu.junior.domain.PageParam;
import com.zhangxu.junior.domain.Student;
import com.zhangxu.junior.service.impl.CourseaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.awt.*;
import java.util.List;
import java.util.Map;

/**
 * @Author zhang xu
 * @Date 2022/6/21 17:09
 * @PackageName:com.zhangxu.junior.controller
 * @ClassName: CourseController
 * @Description: TODO
 * @Version 1.0
 */
@RestController
public class CourseController {

    @Autowired
    CourseaService courseaService;

    @GetMapping("/courseList")
    public List<Course> sleectCourseList(@RequestBody Course course,Integer pageNum, Integer pageSize){
        PageParam pageParam =new PageParam();

        pageParam.setPageNum(pageNum);
        pageParam.setPageSize(pageSize);
        PageHelper.startPage(pageParam);

        return courseaService.sleectCourseList(course);
    }

    @PostMapping("/insertCourse")
    public boolean insertCourse(@RequestBody Course course){
        return courseaService.insertCourse(course);
    }

    @DeleteMapping("/delteCourse")
    public Map<String,String> delteCourse(Long id){
        return courseaService.delteCourse(id);
    }
}

